<?php
    require_once("lib/includes.php");

    $action = new Action();

    echo json_encode(
        $action->Invoke(function(JSONReply $reply)
        {
            $gameId = (int)$_POST['gameid'];

            DB::Connect();

            Queries::UpdateLastActivity($gameId);

            $stmt = Queries::GetTopGuesses($gameId, 1, Constants::MaximumAltResults);

            while ($row = $stmt->fetch_assoc())
            {
                $results[] = array(	"ObjectId" => $row['ObjectID'],
                                    "Name" => $row['Name']);
            }

            $stmt->close();

            $reply->SetData($results);

            DB::Disconnect();
        }));
